package com.mengdie.shuidi.ui.dialog;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import com.mengdie.shuidi.R;
import com.mengdie.shuidi.helper.UIHelper;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;


/**
 * Created by apple on 16/10/14.
 */

public class TipDialogFragment extends DialogFragment {


    @Bind(R.id.iv_tips_bg)
    ImageView mIvTipsBg;
    @Bind(R.id.iv_tips_close)
    ImageView mIvTipsClose;
    @Bind(R.id.tv_tips_top)
    TextView mTvTipsTop;
    @Bind(R.id.tv_tips_bottom)
    TextView mTvTipsBottom;
    @Bind(R.id.iv_tips_submit)
    ImageView mIvTipsSubmit;

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.Dialog_Tips);
        LayoutInflater inflater = getActivity().getLayoutInflater();
        View view = inflater.inflate(R.layout.dialog_tips, null);
        builder.setView(view);
        builder.setCancelable(true);
        ButterKnife.bind(this, view);

        return builder.create();
    }


    @Override
    public void onStart() {
        super.onStart();
        Window window = getDialog().getWindow();
        WindowManager.LayoutParams wlp = window.getAttributes();
        wlp.gravity = Gravity.CENTER;
        wlp.width = WindowManager.LayoutParams.WRAP_CONTENT;
        window.setAttributes(wlp);
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick({R.id.iv_tips_close, R.id.iv_tips_submit})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_tips_close:
                dismiss();
                break;
            case R.id.iv_tips_submit:
                UIHelper.bindPhonePage(getActivity());
//                Intent regist = new Intent(RegistActivity.this, BindPhoneActivity.class);
//                Bundle bundle = new Bundle();
//                bundle.putString("name", name);
//                regist.putExtras(bundle);
//                startActivity(regist);
//                finish();
                dismiss();
                break;
        }
    }
}
